|
In computing, a linear-feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. The most commonly used linear function of single bits is exclusive-or (XOR). Thus, an LFSR is most often a shift register whose input bit is driven by the XOR of some bits of the overall shift register value. The initial value of the LFSR is called the seed, and because the operation of the register is deterministic, the stream of values produced by the register is completely determined by its current (or previous) state. Likewise, because the register has a finite number of possible states, it must eventually enter a repeating cycle. However, an LFSR with a well-chosen feedback function can produce a sequence of bits which appears random and which has a very long cycle. Applications of LFSRs include generating pseudo-random numbers, pseudo-noise sequences, fast digital counters, and whitening sequences. Both hardware and software implementations of LFSRs are common. The mathematics of a cyclic redundancy check, used to provide a quick check against transmission errors, are closely related to those of an LFSR. == Fibonacci LFSRs == The bit positions that affect the next state are called the taps. In the diagram the taps are (). The rightmost bit of the LFSR is called the output bit. The taps are XOR'd sequentially with the output bit and then fed back into the leftmost bit. The sequence of bits in the rightmost position is called the output stream. * The bits in the LFSR state that influence the input are called ''taps'' (white in the diagram). * A maximum-length LFSR produces an m-sequence (i.e. it cycles through all possible 2''n'' − 1 states within the shift register except the state where all bits are zero), unless it contains all zeros, in which case it will never change. * As an alternative to the XOR-based feedback in an LFSR, one can also use XNOR.〔(Linear Feedback Shift Registers in Virtex Devices )〕 This function is an affine map, not strictly a linear map, but it results in an equivalent polynomial counter whose state is the complement of the state of an LFSR. A state with all ones is illegal when using an XNOR feedback, in the same way as a state with all zeroes is illegal when using XOR. This state is considered illegal because the counter would remain "locked-up" in this state. The sequence of numbers generated by an LFSR or its XNOR counterpart can be considered a binary numeral system just as valid as Gray code or the natural binary code. The arrangement of taps for feedback in an LFSR can be expressed in finite field arithmetic as a polynomial mod 2. This means that the coefficients of the polynomial must be 1's or 0's. This is called the feedback polynomial or reciprocal characteristic polynomial. For example, if the taps are at the 16th, 14th, 13th and 11th bits (as shown), the feedback polynomial is : The 'one' in the polynomial does not correspond to a tap – it corresponds to the input to the first bit (i.e. ''x0'', which is equivalent to 1). The powers of the terms represent the tapped bits, counting from the left. The first and last bits are always connected as an input and output tap respectively. The LFSR is maximal-length if and only if the corresponding feedback polynomial is primitive. This means that the following conditions are necessary (but not sufficient): * The number of taps should be even. * The set of taps – taken all together, ''not'' pairwise (i.e. as pairs of elements) – must be relatively prime. In other words, there must be no divisor other than 1 common to all taps. Tables of primitive polynomials from which maximum-length LFSRs can be constructed are given below and in the references. There can be more than one maximum-length tap sequence for a given LFSR length. Also, once one maximum-length tap sequence has been found, another automatically follows. If the tap sequence, in an ''n''-bit LFSR, is (), where the 0 corresponds to the ''x''0 = 1 term, then the corresponding 'mirror' sequence is (). So the tap sequence () has as its counterpart (). Both give a maximum-length sequence. Some example C code is below: This LFSR configuration is also known as standard, many-to-one or external XOR gates. The alternative Galois configuration is described in the next section. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Linear feedback shift register」の詳細全文を読む スポンサード リンク
|